package org.mat.ipaas.ucenter.service.api.system;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysAnnouncementDTO;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysAnnouncementSendDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @Title: Controller
 * 系统通告表
 */
@FeignClient(name = "mat-ipaas-ucenter-service", contextId = "sys-announcement-rest-api")
public interface SysAnnouncementRestAPI {

    /**
     * 分页列表查询
     *
     * @param sysAnnouncementDTO
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/list", method = RequestMethod.GET)
    MatApiResponse<Page<SysAnnouncementDTO>> queryPageList(@SpringQueryMap SysAnnouncementDTO sysAnnouncementDTO,
                                                            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize);

    /**
     * 添加
     *
     * @param sysAnnouncementDTO
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/add", method = RequestMethod.POST)
    MatApiResponse<SysAnnouncementDTO> add(@RequestBody SysAnnouncementDTO sysAnnouncementDTO);

    /**
     * 编辑
     *
     * @param sysAnnouncementDTO
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/edit", method = {RequestMethod.POST})
    MatApiResponse<SysAnnouncementDTO> eidt(@RequestBody SysAnnouncementDTO sysAnnouncementDTO);

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/delete", method = RequestMethod.DELETE)
    MatApiResponse<SysAnnouncementDTO> delete(@RequestParam(name = "id", required = true) String id);

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/deleteBatch", method = RequestMethod.DELETE)
    MatApiResponse<SysAnnouncementDTO> deleteBatch(@RequestParam(name = "ids", required = true) String ids);

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/queryById", method = RequestMethod.GET)
    MatApiResponse<SysAnnouncementDTO> queryById(@RequestParam(name = "id", required = true) String id);

    /**
     * 更新发布操作
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/doReleaseData", method = RequestMethod.GET)
    MatApiResponse<SysAnnouncementDTO> doReleaseData(@RequestHeader("X-Access-Token") String accessToken,
                                                     @RequestParam(name = "id", required = true) String id);

    /**
     * 更新撤销操作
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/doReovkeData", method = RequestMethod.GET)
    MatApiResponse<SysAnnouncementDTO> doReovkeData(@RequestParam(name = "id", required = true) String id);

    /**
     * @return
     * @功能：补充用户数据，并返回系统消息
     */
    @RequestMapping(value = "/sys/annountCement/listByUser", method = RequestMethod.GET)
    MatApiResponse<Map<String, Object>> listByUser(@RequestParam(required = false, defaultValue = "5") Integer pageSize);


    /**
     * 导出excel
     *
     * 
     */
    @RequestMapping(value = "/sys/annountCement/exportXls")
    ModelAndView exportXls(SysAnnouncementDTO sysAnnouncementDTO);

    /**
     * 通过excel导入数据
     *
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/importExcel", method = RequestMethod.POST)
    MatApiResponse<?> importExcel();


    /**
     * 同步消息
     *
     * @param anntId
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/syncNotic", method = RequestMethod.GET)
    MatApiResponse<SysAnnouncementDTO> syncNotic(@RequestParam(name = "anntId", required = false) String anntId);

    /**
     * 通告查看详情页面（用于第三方APP）
     *
     * @param modelAndView
     * @param id
     * @return
     */
    @GetMapping("/sys/annountCement/show/{id}")
    ModelAndView showContent(ModelAndView modelAndView, @PathVariable("id") String id);

    /**
     * 【vue3用】 消息列表查询
     *
     * @param fromUser
     * @param beginDate
     * @param endDate
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/sys/annountCement/vue3List", method = RequestMethod.GET)
    MatApiResponse<List<SysAnnouncementDTO>> vue3List(@RequestParam(name = "fromUser", required = false) String fromUser,
                                                      @RequestParam(name = "starFlag", required = false) String starFlag,
                                                      @RequestParam(name = "rangeDateKey", required = false) String rangeDateKey,
                                                      @RequestParam(name = "beginDate", required = false) String beginDate, @RequestParam(name = "endDate", required = false) String endDate,
                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize);

    /**
     * 根据用户id获取最新一条消息发送时间(创建时间)
     *
     * @param userId
     * @return
     */
    @GetMapping("/sys/annountCement/getLastAnnountTime")
    MatApiResponse<Page<SysAnnouncementSendDTO>> getLastAnnountTime(@RequestParam(name = "userId") String userId);
}
